﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using App.Common;
using QxFramework.Core;
public class ExplodeBullet : BulletBase
{
    public string Explode = "Explosion1";

    public override void Update()
    {
        base.Update();
    }

    private void Destoyed()
    {
        Hit();
        GameMgr.Get<IBulletManager>().RemoveMono(gameObject.name);
    }

    public override void OnOutofRange()
    {
        HitOthersEffect(transform.position);
        base.OnOutofRange();
    }
    public override void OnHitOthers(GameObject other)
    {
        base.OnHitOthers(other);
        if (other.GetComponent<MonoBase>() != null)
        {
            other.GetComponent<MonoBase>().LastTimeMove(bulletBase.Direction, bulletBase.Speed / 2, 6, () => { });
        }
    }
    private void Hit()
    {
        GameMgr.Get<IBuffManager>().Explosion(bulletBase.attribute, transform.position, Explode);
    }
    public override void OnDestroyed()
    {
        base.OnDestroyed();
        Destoyed();
    }

    private void OnCollisionEnter2D(Collision2D collision)
    {
        OnHitOthers(collision.gameObject);
    }
}
